package com.hngy.xpq.android_practice.merchant_main;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.hngy.xpq.android_practice.R;
import com.hngy.xpq.android_practice.assets.XpqIcoMoon;
import com.hngy.xpq.android_practice.assets.XpqIcoMoonUtils;
import com.hngy.xpq.android_practice.bean.Wallet;
import com.hngy.xpq.android_practice.merchant_main.Comm.CommMerchantActivity;
import com.hngy.xpq.android_practice.merchant_main.Comm.Comm_query;
import com.hngy.xpq.android_practice.ui.notifications.NotificatiosOrder;
import com.hngy.xpq.android_practice.ui.notifications.WalletActivity;
import com.hngy.xpq.android_practice.ui.notifications.WalletQuery;

public class MerchantMainActivity extends AppCompatActivity {

    SharedPreferences notification,comm;
    Button enter,shop,wallet,order,tuichu;    //功能
    TextView name,f,r,w;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.merchant_home_main);
        //商家信息的完善
        notification = getSharedPreferences("merchants",MODE_PRIVATE);
        comm = getSharedPreferences("comm",MODE_PRIVATE);
        name = findViewById(R.id.merchant_name);
        name.setText(notification.getString("name",""));

        //文字图标的显示
        enter = findViewById(R.id.merchant_ENTER);
        enter.setText(XpqIcoMoon.ENTER);
        shop = findViewById(R.id.merchant_SHOP);
        shop.setText(XpqIcoMoon.SHOP);
        order = findViewById(R.id.merchant_ORDER);
        order.setText(XpqIcoMoon.ORDER);
        wallet = findViewById(R.id.merchant_WALLET);
        wallet.setText(XpqIcoMoon.WALLET);
        XpqIcoMoonUtils.setIOC(enter,shop,order,wallet);

        //上架商品界面的 跳转
        enter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MerchantMainActivity.this, CommMerchantActivity.class);
                startActivity(intent);
            }
        });

        //商品管理界面的 跳转
        shop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences.Editor editor = comm.edit();
                editor.putString("name",notification.getString("name",""));
                editor.commit();
                Intent intent = new Intent(MerchantMainActivity.this, Comm_query.class);
                startActivity(intent);
            }
        });

        //订单管理界面的 跳转
        order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MerchantMainActivity.this, NotificatiosOrder.class);
                startActivity(intent);
            }
        });

        //钱包收益界面的 跳转
        wallet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MerchantMainActivity.this , WalletActivity.class);
                startActivity(intent);
            }
        });
    }
}